//
//  ViewController.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/6.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "ViewController.h"
#import "SecViewController.h"
@interface ViewController ()<UIViewControllerPreviewingDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

[self registerForPreviewingWithDelegate:self sourceView:self.view];

}

- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    SecViewController *vc = [sb instantiateViewControllerWithIdentifier:@"SecViewController"];
    vc.preferredContentSize = CGSizeMake(0.0f, [[UIScreen mainScreen] bounds].size.height - 100);
    vc.sourceVC = self;
    
    CGRect rect = CGRectMake(10, location.y - 10, self.view.frame.size.width - 20, 50);//这个50的高度是点击触发3D Touch的高度，如果像短信之类的是表格，一般就是表格的高度
    previewingContext.sourceRect = rect;
    
    return vc;
}

- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
{
    [self showViewController:viewControllerToCommit sender:self];
}

@end
